import axios from 'axios'
import { getToken } from '../utils/tokenMgr'

const service=axios.create({
    baseURL:'https://api-hmzs.itheima.net/tj',
    timeout:5000,
})

service.interceptors.request.use(config=>{
    const token=getToken()
    if(token){
        config.headers.Authorization=token
    }
    return config
},error=>{
    return Promise.reject(error)
})

service.interceptors.response.use((response)=>{
    return response.data
},(error)=>{
    return Promise.reject(error)
})

export default service